home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / memory_.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.8 KB  |  112 lines

  1. /* Copyright (C) 1989, 1992, 1993, 1994, 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: memory_.h,v 1.2 2000/09/19 19:00:47 lpd Exp $ */
  20. /* Generic substitute for Unix memory.h */
  21.  
  22. #ifndef memory__INCLUDED
  23. #  define memory__INCLUDED
  24.  
  25. /* We must include std.h before any file that includes sys/types.h. */
  26. #include "std.h"
  27.  
  28. /******
  29.  ****** Note: the System V bcmp routine only returns zero or non-zero,
  30.  ****** unlike memcmp which returns -1, 0, or 1.
  31.  ******/
  32.  
  33. #ifdef __TURBOC__
  34. /* Define inline functions */
  35. #  ifdef __WIN32__
  36. #    define memcmp_inline(b1,b2,len) memcmp(b1,b2,len)
  37. #  else
  38. #    define memcmp_inline(b1,b2,len) __memcmp__(b1,b2,len)
  39. #  endif
  40. #  include <mem.h>
  41. #else
  42.     /* Not Turbo C, no inline functions */
  43. #  define memcmp_inline(b1,b2,len) memcmp(b1,b2,len)
  44.     /*
  45.      * Apparently the newer VMS compilers include prototypes
  46.      * for the mem... routines in <string.h>.  Unfortunately,
  47.      * gcc lies on Sun systems: it defines __STDC__ even if
  48.      * the header files in /usr/include are broken.
  49.      * However, Solaris systems, which define __svr4__, do have
  50.      * correct header files.
  51.      */
  52.     /*
  53.      * The exceptions vastly outnumber the BSD4_2 "rule":
  54.      * these tests should be the other way around....
  55.      */
  56. #  if defined(VMS) || defined(_POSIX_SOURCE) || (defined(__STDC__) && (!defined(sun) || defined(__svr4__))) || defined(_HPUX_SOURCE) || defined(__WATCOMC__) || defined(THINK_C) || defined(bsdi) || defined(__FreeBSD) || (defined(_MSC_VER) && _MSC_VER >= 1000)
  57. #    include <string.h>
  58. #  else
  59. #    if defined(BSD4_2) || defined(UTEK)
  60. extern bcopy(), bcmp(), bzero();
  61.  
  62. #     define memcpy(dest,src,len) bcopy(src,dest,len)
  63. #     define memcmp(b1,b2,len) bcmp(b1,b2,len)
  64.      /* Define our own versions of missing routines (in gsmisc.c). */
  65. #     define MEMORY__NEED_MEMMOVE
  66. #        include <sys/types.h>    /* for size_t */
  67. #     define MEMORY__NEED_MEMSET
  68. #     if defined(UTEK)
  69. #          define MEMORY__NEED_MEMCHR
  70. #        endif            /* UTEK */
  71. #    else
  72. #      include <memory.h>
  73. #      if defined(__SVR3) || defined(sun)    /* Not sure this is right.... */
  74. #     define MEMORY__NEED_MEMMOVE
  75. #        include <sys/types.h>    /* for size_t */
  76. #      endif            /* __SVR3 or sun */
  77. #    endif            /* BSD4_2 or UTEK */
  78. #  endif            /* VMS, POSIX, ... */
  79. #endif /* !__TURBOC__ */
  80.  
  81. /*
  82.  * If we are profiling, substitute our own versions of memset, memcpy,
  83.  * and memmove, in case profiling libraries aren't available.
  84.  */
  85. #ifdef PROFILE
  86. #  define MEMORY__NEED_MEMCPY
  87. #  define MEMORY__NEED_MEMMOVE
  88. #  define MEMORY__NEED_MEMSET
  89. #endif
  90.  
  91. /* Declare substitutes for library procedures we supply. */
  92. #ifdef MEMORY__NEED_MEMMOVE
  93. #  define memmove(dest,src,len) gs_memmove(dest,src,len)
  94. void *gs_memmove(P3(void *, const void *, size_t));
  95. #endif
  96. #ifdef MEMORY__NEED_MEMCPY
  97. #  define memcpy(dest,src,len) gs_memcpy(dest,src,len)
  98. void *gs_memcpy(P3(void *, const void *, size_t));
  99. #endif
  100. #ifdef MEMORY__NEED_MEMSET
  101. #  define memset(dest,ch,len) gs_memset(dest,ch,len)
  102. void *gs_memset(P3(void *, int, size_t));
  103. #endif
  104. #ifdef MEMORY__NEED_MEMCHR
  105. #  define memchr(ptr,ch,len) gs_memchr(ptr,ch,len)
  106. void *gs_memchr(P3(const void *, int, size_t));
  107. #endif
  108.  
  109.  
  110.  
  111. #endif /* memory__INCLUDED */
  112.